using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace PacSnake
{
	/// <summary>
	/// Summary description for FormSkins.
	/// </summary>
	public class FormSkins : System.Windows.Forms.Form
	{
        // Selected Skin object
        private Skin skin;
        
        // Holds a collection of Skin objects
        private SkinCollection skins = new SkinCollection();

	    // Checks if we pressed OK or cancel
	    private bool okButtonPressed = false;
	    
	    
	    #region Constructor
	    
	    /// <summary>
	    /// Constructor: Fills the listbox with available skins
	    /// </summary>
		public FormSkins(string skinFilename)
		{
			InitializeComponent();
			
            // Loads all skins
            skins.LoadSkins();
			
            // Adds the name of each skin to the listbox
            for (int i = 0; i < skins.Count; i++)
            {
                lstSkins.Items.Add(skins[i].Name);
                
                if (skins[i].Filename == skinFilename)
                    lstSkins.SelectedIndex = i;
            }
            
            //lstSkins.SelectedIndex = 0;
		}

        #endregion

        #region Events for the listbox and buttons
        
        /// <summary>
        /// Update the skin information in the labels when the user selects a
        /// different skin.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lstSkins_SelectedIndexChanged(object sender,
            System.EventArgs e)
        {
            int index = lstSkins.SelectedIndex;
            skin = (Skin)skins[index];
            
            lblAuthor.Text = skin.Author;
        }
        
        
        /// <summary>
        /// Set the name and filename of the level set
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, System.EventArgs e)
        {
            okButtonPressed = true;
            this.Close();
        }

        
        /// <summary>
        /// Cancel pressed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, System.EventArgs e)
        {
            this.Close();
        }
		
		#endregion
		
        #region Properties
        
        public Skin Skin
        {
            get { return skin; }
        }
        
        public bool OkButtonPressed
        {
            get { return okButtonPressed; }
        }
        
        #endregion

		#region Windows Form Designer generated code
		
        private System.Windows.Forms.Button btnCancel;
        private System.Windows.Forms.Button btnOk;
        private System.Windows.Forms.GroupBox grpSkins;
        private System.Windows.Forms.PictureBox pbxPreview;
        private System.Windows.Forms.Label lblPreview;
        private System.Windows.Forms.Label lblSkins;
        private System.Windows.Forms.ListBox lstSkins;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.Label lblTitle;
        private System.Windows.Forms.Label lblAuthor;
        private System.Windows.Forms.Label lblAuthorH;
        
		private System.ComponentModel.Container components = null;
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FormSkins));
            this.btnCancel = new System.Windows.Forms.Button();
            this.btnOk = new System.Windows.Forms.Button();
            this.grpSkins = new System.Windows.Forms.GroupBox();
            this.lblAuthor = new System.Windows.Forms.Label();
            this.lblAuthorH = new System.Windows.Forms.Label();
            this.pbxPreview = new System.Windows.Forms.PictureBox();
            this.lblPreview = new System.Windows.Forms.Label();
            this.lblSkins = new System.Windows.Forms.Label();
            this.lstSkins = new System.Windows.Forms.ListBox();
            this.panel1 = new System.Windows.Forms.Panel();
            this.lblTitle = new System.Windows.Forms.Label();
            this.grpSkins.SuspendLayout();
            this.panel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // btnCancel
            // 
            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.btnCancel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.btnCancel.Location = new System.Drawing.Point(256, 312);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.TabIndex = 24;
            this.btnCancel.Text = "Cancel";
            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
            // 
            // btnOk
            // 
            this.btnOk.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.btnOk.Location = new System.Drawing.Point(168, 312);
            this.btnOk.Name = "btnOk";
            this.btnOk.TabIndex = 23;
            this.btnOk.Text = "OK";
            this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
            // 
            // grpSkins
            // 
            this.grpSkins.Controls.Add(this.lblAuthor);
            this.grpSkins.Controls.Add(this.lblAuthorH);
            this.grpSkins.Controls.Add(this.pbxPreview);
            this.grpSkins.Controls.Add(this.lblPreview);
            this.grpSkins.Controls.Add(this.lblSkins);
            this.grpSkins.Controls.Add(this.lstSkins);
            this.grpSkins.Location = new System.Drawing.Point(8, 64);
            this.grpSkins.Name = "grpSkins";
            this.grpSkins.Size = new System.Drawing.Size(488, 232);
            this.grpSkins.TabIndex = 22;
            this.grpSkins.TabStop = false;
            // 
            // lblAuthor
            // 
            this.lblAuthor.Location = new System.Drawing.Point(240, 24);
            this.lblAuthor.Name = "lblAuthor";
            this.lblAuthor.Size = new System.Drawing.Size(168, 16);
            this.lblAuthor.TabIndex = 8;
            // 
            // lblAuthorH
            // 
            this.lblAuthorH.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.lblAuthorH.Location = new System.Drawing.Point(160, 24);
            this.lblAuthorH.Name = "lblAuthorH";
            this.lblAuthorH.Size = new System.Drawing.Size(80, 16);
            this.lblAuthorH.TabIndex = 7;
            this.lblAuthorH.Text = "Author:";
            // 
            // pbxPreview
            // 
            this.pbxPreview.Location = new System.Drawing.Point(160, 72);
            this.pbxPreview.Name = "pbxPreview";
            this.pbxPreview.Size = new System.Drawing.Size(312, 136);
            this.pbxPreview.TabIndex = 4;
            this.pbxPreview.TabStop = false;
            // 
            // lblPreview
            // 
            this.lblPreview.Location = new System.Drawing.Point(160, 48);
            this.lblPreview.Name = "lblPreview";
            this.lblPreview.Size = new System.Drawing.Size(120, 16);
            this.lblPreview.TabIndex = 3;
            this.lblPreview.Text = "Preview:";
            // 
            // lblSkins
            // 
            this.lblSkins.Location = new System.Drawing.Point(16, 24);
            this.lblSkins.Name = "lblSkins";
            this.lblSkins.Size = new System.Drawing.Size(120, 16);
            this.lblSkins.TabIndex = 2;
            this.lblSkins.Text = "Skins:";
            // 
            // lstSkins
            // 
            this.lstSkins.Location = new System.Drawing.Point(16, 40);
            this.lstSkins.Name = "lstSkins";
            this.lstSkins.Size = new System.Drawing.Size(120, 173);
            this.lstSkins.TabIndex = 0;
            this.lstSkins.SelectedIndexChanged += new System.EventHandler(this.lstSkins_SelectedIndexChanged);
            // 
            // panel1
            // 
            this.panel1.BackColor = System.Drawing.Color.White;
            this.panel1.Controls.Add(this.lblTitle);
            this.panel1.Location = new System.Drawing.Point(0, 0);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(508, 56);
            this.panel1.TabIndex = 21;
            // 
            // lblTitle
            // 
            this.lblTitle.Font = new System.Drawing.Font("Arial Black", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.lblTitle.Location = new System.Drawing.Point(16, 16);
            this.lblTitle.Name = "lblTitle";
            this.lblTitle.Size = new System.Drawing.Size(208, 23);
            this.lblTitle.TabIndex = 0;
            this.lblTitle.Text = "Select Skin";
            // 
            // FormSkins
            // 
            this.AcceptButton = this.btnOk;
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.CancelButton = this.btnCancel;
            this.ClientSize = new System.Drawing.Size(504, 347);
            this.Controls.Add(this.btnCancel);
            this.Controls.Add(this.btnOk);
            this.Controls.Add(this.grpSkins);
            this.Controls.Add(this.panel1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "FormSkins";
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
            this.Text = "Select Skin";
            this.grpSkins.ResumeLayout(false);
            this.panel1.ResumeLayout(false);
            this.ResumeLayout(false);

        }
        
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if(components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }
        
		#endregion
	}
}
